#!/usr/bin/ruby
require 'fileutils'

source = 'output'
target = ARGV[0]

# ./etc/init/usart_service.cfg:5:                "start usart_service"
`sudo mkdir -p #{target}/system/etc/init`
FileUtils.copy("#{source}/cfg/usart_service.cfg","#{target}/system/etc/init/usart_service.cfg")

# grep: ./bin/usart_test3：匹配到二进制文件
# grep: ./bin/usart_test：匹配到二进制文件
# grep: ./bin/usart_test2：匹配到二进制文件
`sudo mkdir -p #{target}/system/bin`
["",'2','3'].each do |suffix|
	FileUtils.copy("#{source}/bin/usart_test#{suffix}","#{target}/system/bin/usart_test#{suffix}")
end

# ./profile/usart_service.xml:3:    <process>usart_service</process>
`sudo mkdir -p #{target}/system/profile`
FileUtils.copy("#{source}/xml/usart_service.xml","#{target}/system/profile/usart_service.xml")

# grep: ./lib64/module/multimedia/libusart.z.so：匹配到二进制文件
`sudo mkdir -p #{target}/system/lib64/module/multimedia`
FileUtils.copy("#{source}/lib/libusart.z.so","#{target}/system/lib64/module/multimedia/libusart.z.so")

# grep: ./lib64/libusart_service.z.so：匹配到二进制文件

FileUtils.copy("#{source}/lib/libusart_service.z.so","#{target}/system/lib64/libusart_service.z.so")